<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>添加分类页</title>
</head>
<body>
<form id="formm">
	<table>
		<tr>
			<th>商品名：</th>
			<th><input type="text" name="name"></th>
			<th>商品价格：</th>
			<th><input type="text" name="price"></th>
			<th><select name="cate_id">
				{% for cate in cates %}
					<option value="{{ cate.id }}">{{ cate.name }}</option>
				{% endfor %}
			</select></th>
			<th><input type="button" id="activee" value="添加商品"></th>
		</tr>
	</table>
</form>
<script src="/static/news/js/jquery-1.12.4.min.js"></script>
<script>

    $("#activee").click(function () {
        formdata = new FormData($("#formm")[0]);
        $.ajax({
            url: "/addgoods",
            method: "post",
            data: formdata,
            processData: false,
            contentType: false,
            success: function (formdata) {
                alert("添加成功");
                console.log(formdata)
            },
            error: function (error) {
                alert("添加失败");
                console.log(error)
            }
        })
    })

</script>
</body>
</html>